//
//  SISSContractOnlyRightFillInCell.m
//  SISSAPP
//
//  Created by 袁应荣 on 2017/9/22.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSContractOnlyRightFillInCell.h"

@interface SISSContractOnlyRightFillInCell ()<UITextFieldDelegate>

/// textField
@property (weak, nonatomic) UITextField *textField;
/* bottomLine */
@property (weak, nonatomic) UIView *bottomLine;

@end
@implementation SISSContractOnlyRightFillInCell



- (void)setContractModel:(SISSContractModel *)contractModel {
    [super setContractModel:contractModel];
    
    self.textField.placeholder = contractModel.placeHolder;
    self.textField.text = contractModel.rightStr;
}

#pragma mark - UITextFieldDelegate
- (void)textFieldDidEndEditing:(UITextField *)textField {
    self.contractModel.rightStr = textField.text;
}


#pragma mark - UI
- (void)initUI {
    [super initUI];
    
    UITextField *textField = [[UITextField alloc] init];
    textField.delegate = self;
    textField.textColor = MAIN_TEXT_COLOR;
    textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@" " attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:SECONDARY_TEXT_COLOR}];
    [self.contentView addSubview:textField];
    self.textField = textField;
    
    UIView *bottomLine = [[UIView alloc] init];
    bottomLine.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.contentView addSubview:bottomLine];
    self.bottomLine = bottomLine;

}

#pragma mark - 约束
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGFloat margin = 8.0;
    [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.contentView).offset(-2 * margin);
        make.centerY.equalTo(weakSelf.contentView);
    }];
    
    [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.textField.mas_bottom).offset(1.5 * margin);
        make.left.right.bottom.equalTo(weakSelf.contentView);
        make.height.mas_equalTo(1);
    }];
}

@end
